<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePreparationTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {

        Schema::create('car_stay_time_levels', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('level')->comment('停留时间等级')->unique();
            $table->string('desc')->comment('备注')->unique();
            $table->timestamps();
        });
        //工作量预设
        Schema::create('car_preparations', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->float('work_time')->comment('工作时间上限')->nullable();
            $table->float('fill_time')->comment('一次加水时间')->nullable();
            $table->integer('area_id')->unsigned()->comment('工作区域');
            $table->float('work_speed_low')->unsigned()->comment('作业行驶速度下限');
            $table->float('work_speed_high')->unsigned()->comment('作业行驶速度上限');
            $table->float('non_work_speed_low')->unsigned()->comment('非作业行驶速度下限');
            $table->float('non_work_speed_high')->unsigned()->comment('非作业行驶速度上限');
            $table->bigInteger('level_id')->unsigned()->comment('停留时间等级')->nullable();
            $table->unsignedInteger('kind_id')->comment('预设车辆类型')->nullable();
            $table->foreign('kind_id')->references('id')->on('carkinds')->onDelete('set null');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('car_preparations');
        Schema::dropIfExists('car_stay_time_levels');
    }
}
